'use strict';

function compute_median(collection) {
  var ab,answer;
  function sortNumber(a,b){
    return a-b;
  }
    ab=collection.sort(sortNumber);
       console.log(ab);
       var i=ab.length/2;
  if(ab.length%2==0){
       answer=(ab[i]+ab[i-1])/2;
  }else{
       answer=ab[ parseInt(ab.length/2)];
  }
      console.log(answer); 
  return answer; //在这里写入代码
}

module.exports = compute_median;


